<form (ngSubmit)="register()" #form="ngForm">
  <!-- 没有#f #phone = ngModel报错 to get reason -->
  <!-- ()输出 【】输入 -->
  <div class="from-group">
    <input
      type="text"
      class="form-control"
      [(ngModel)]="model.phone"
      name="phone"
      pattern="1\d{10}"
      required
      placeholder="手机号"
      #phone="ngModel"
    />
    <!-- [] == :  -->
    <!-- #phone 模板引用变量 -->
    <div class="error" [hidden]="phone.valid || phone.untouched">
      <!-- ?. == e&&e.phoen&& -->
      <span *ngIf="phone?.errors?.required">请输入</span>
      <span *ngIf="phone?.errors?.pattern">格式异常</span>
    </div>
  </div>
  <div class="from-group">
    <input
      type="password"
      class="form-control"
      [(ngModel)]="model.pwd"
      name="pwd"
      placeholder="密码"
      required
      #pwd="ngModel"
    />
    <!-- {{ pwd.value }}
      {{ pwd }} -->
    <div class="error" [hidden]="pwd.valid || pwd.untouched">
      <!-- ?. == e&&e.phoen&& -->
      <span *ngIf="pwd?.errors?.required">请输入</span>
    </div>
  </div>
  <div class="from-group">
    <input
      type=""
      class="form-control"
      [(ngModel)]="model.codeMsg"
      name="codeMsg"
      placeholder="codeMsg"
      required
      #codeMsg="ngModel"
    />
    <!-- {{ pwd.value }}
      {{ pwd }} -->
    <div class="error" [hidden]="codeMsg.valid || pwd.untouched">
      <!-- ?. == e&&e.phoen&& -->
      <span *ngIf="pwd?.errors?.required">请输入</span>
    </div>
  </div>
  <div class="from-group">
    <div class="code-img-box">
      <input
        type=""
        class="form-control"
        [(ngModel)]="model.codeImg"
        name="codeImg"
        placeholder="codeImg"
        required
        #codeImg="ngModel"
      />
      <img
        [src]="codeImgSrc"
        alt=""
        width="90"
        height="46"
        (click)="getCodeImg()"
      />
      <a (click)="getCodeImg()">刷新</a>
    </div>

    <!-- {{ pwd.value }}
      {{ pwd }} -->
    <div class="error" [hidden]="pwd.valid || pwd.untouched">
      <!-- ?. == e&&e.phoen&& -->
      <span *ngIf="pwd?.errors?.required">请输入</span>
    </div>
  </div>
  <button
    type="submit"
    [disabled]="form.invalid"
    class="btn btn-primary from-group"
  >
    登录
  </button>
</form>
